package org.flexharmony.eclipse.properties.preferences;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.flexharmony.eclipse.properties.PropertiesPanel;

public class DefaultPreferencesPage extends PreferencePage implements IWorkbenchPreferencePage
{
  private PropertiesPanel propertiesPanel;

  public DefaultPreferencesPage()
  {
    super("FlexHarmony");
    setDescription("Default FlexHarmony project properties");
  }

  /**
   * @see IWorkbenchPreferencePage#init(IWorkbench)
   */
  public void init(IWorkbench workbench)
  {}

  @Override
  public boolean performOk() 
  {
    try
    {
      propertiesPanel.save();
      return true;
    }
    catch (CoreException cexc)
    {
      cexc.printStackTrace();
      return false;
    }
  }


  @Override
  protected Control createContents(Composite parent)
  {
    propertiesPanel = new PropertiesPanel(null, parent);
    return propertiesPanel;
  }
}
